#!/bin/bash

COL_HL="\033[44;33m"
COL_NORMAL="\033[0m"

function prj_temp() {
	echo "PRJ_NAME       = \"[${prj_name}]\""
	echo "PRJ_VERSION    = "1""
	echo "PRJ_PATCHLEVEL = "0""
	echo "PRJ_SUBLEVEL   = "0""


	echo "# default download.elf,download.dis,download.bin"
	echo "OUTPUT_ELF	= default.elf"
	echo "# OUTPUT_DIS	= "
	echo "# OUTPUT_BIN	= "
	echo "# OUTPUT_SO 	= "
	echo "# OUTPUT_A	= "
	echo "# OUTPUT_DIR 	= "



	echo "INCLUDE_DIR	+="
	echo "LFLAGS		+= -lla -llb"
	echo "LIB_DIR 	+="
	echo "CFLAGS      	+="
}

function create_project() {
	prj_temp > a.txt

}

function output_dir() {
	# echo -n "please output directory: "
	# echo prj_type ${prj_type}
	if [ ${prj_type} == "elf" ]
	then
		output_dir="release"
	else
		output_dir="lib"
	fi
	# echo "select $prj_name"
}

function project_name() {
	echo -e "${COL_HL}"
	echo -n " please write your project names:    "
	read prj_name
	echo "select $prj_name"
	echo -e "${COL_NORMAL}"
}


function project_type() {
	

	echo "  1. ELF --- [default]"
	echo "  2. Dynamic/Static library"
	echo "  3. Binary"

	echo -e "${COL_HL}"
	echo  -n " select project type:    "
	read edit
	echo -e "${COL_NORMAL}"

	echo "select $prj_name"
	prj_type="elf"
	case $edit in
		"1") 
			prj_type="elf";;
		"2")
			prj_type="lib";;
		"3")
			prj_type="bin";;
	esac


}









function enter_sure() {
	
	echo -e "\nproject information [Y/N]: "
	read edit
	prj_type="elf"
	case $edit in
		"y") 
			AFFIRM="Y";;
		"Y") 
			AFFIRM="Y";;
		"n") 
			AFFIRM="N";;
		"N")
			AFFIRM="N";;
	esac
}



###########################################################################
# main
#

while [ 1 ]
do
	project_name
	if [ ${prj_name} != "" ]
	then
		break
	fi
done


	

project_type
output_dir

echo "-------------------------------------------------------------"
echo -e "Project name --------------------- ${prj_name}"
echo -e "Output directory ----------------- ${prj_type}"
echo "-------------------------------------------------------------"



while [ 1 ]
do
	enter_sure
	if [ ${AFFIRM} != "" ]
	then
		break
	fi
done

if [ ${AFFIRM} == "Y" ]
then
	create_project
fi

